//
//  SLDBCell.m
//  BaseProject
//
//  Created by hundredsandc on 2017/10/31.
//  Copyright © 2017年 hundredsandc. All rights reserved.
//

#import "SLDBCell.h"
#import "Masonry.h"
@interface SLDBCell ()
@property (weak, nonatomic) IBOutlet UILabel *One;
@property (weak, nonatomic) IBOutlet UILabel *Two;
@property (weak, nonatomic) IBOutlet UILabel *Three;
@property (weak, nonatomic) IBOutlet UILabel *Four;
@property (weak, nonatomic) IBOutlet UILabel *One1;
@property (weak, nonatomic) IBOutlet UILabel *One2;
@property (weak, nonatomic) IBOutlet UILabel *Two1;
@property (weak, nonatomic) IBOutlet UILabel *Two2;
@property (weak, nonatomic) IBOutlet UILabel *Three1;
@property (weak, nonatomic) IBOutlet UILabel *Three2;
@property (weak, nonatomic) IBOutlet UILabel *four1;
@property (weak, nonatomic) IBOutlet UILabel *four2;
@property (nonatomic,assign)NSInteger one1Per;
@property (nonatomic,assign)NSInteger two1Per;
@property (nonatomic,assign)NSInteger three1Per;
@property (nonatomic,assign)NSInteger four1Per;



@end
@implementation SLDBCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self addConstarint];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)customOne1:(NSString *)One1 One2:(NSString*)One2 two1:(NSString *)two1 two2:(NSString *)two2 three1:(NSString *)three1 three2:(NSString *)three2 four1:(NSString *)four1 four2:(NSString *)four2 one1Per:(NSInteger)one1Per two1Per:(NSInteger)two1Per three1Per:(NSInteger)three1Per four1Per:(NSInteger)four1Per{
    
    _One1.hidden = NO;
    _One2.hidden = NO;
    _Two1.hidden = NO;
    _Two2.hidden = NO;
    _Three1.hidden = NO;
    _Three2.hidden = NO;
    _four1.hidden = NO;
    _four2.hidden = NO;
    
    
    _One1.text = One1;
    if ([One1 containsString:@"null"]||[One1 containsString:@"NULL"]) {
        _One1.hidden = YES;
        _One2.hidden = YES;
    }
    _One2.text = One2;
    _Two1.text = two1;
    if ([two1 containsString:@"null"]||[two1 containsString:@"NULL"]) {
        _Two1.hidden = YES;
        _Two2.hidden = YES;
    }
    _Two2.text = two2;
    _Three1.text = three1;
    if ([three1 containsString:@"null"]||[three1 containsString:@"NULL"]||three1==nil) {
        _Three1.hidden = YES;
        _Three2.hidden = YES;
    }
    _Three2.text = three2;
    _four1.text = four1;
    if ([four1 containsString:@"null"]||[four1 containsString:@"NULL"]||four1==nil) {
        _four1.hidden = YES;
        _four2.hidden = YES;
    }
    _four2.text = four2;
    self.one1Per = one1Per;
    self.two1Per = two1Per;
    self.three1Per = three1Per;
    self.four1Per = four1Per;
    
    [self addConstarint];
}
-(void)addConstarint{
    WS(ws);
    float one1Per = self.one1Per/100.00;
    float one2Per = 1-one1Per;
    if (one1Per>0) {
        
        [_One1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_One.mas_bottom).with.offset(2);
            make.left.equalTo(ws.contentView.mas_left).with.offset(20);
            make.width.mas_equalTo((SCREEN_WIDTH-40)*one1Per);
            make.height.mas_equalTo(15);
        }];
        [_One2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_One.mas_bottom).with.offset(2);
            make.right.equalTo(ws.contentView.mas_right).with.offset(-20);
            make.width.mas_equalTo((SCREEN_WIDTH-40)*one2Per);
            make.height.mas_equalTo(15);
        }];
    }
    
    float two1Per = self.two1Per/100.00;
    float two2Per = 1-two1Per;
    if (two1Per>0) {
        
        [_Two1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_Two.mas_bottom).with.offset(2);
            make.left.equalTo(ws.contentView.mas_left).with.offset(20);
            make.width.mas_equalTo((SCREEN_WIDTH-40)*two1Per);
            make.height.mas_equalTo(15);
        }];
        [_Two2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_Two.mas_bottom).with.offset(2);
            make.right.equalTo(ws.contentView.mas_right).with.offset(-20);
            make.width.mas_equalTo((SCREEN_WIDTH-40)*two2Per);
            make.height.mas_equalTo(15);
        }];
    }
    float three1Per = self.three1Per/100.00;
    float three2Per = 1-three1Per;
    if (three1Per>0) {
        
        [_Three1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_Three.mas_bottom).with.offset(2);
            make.left.equalTo(ws.contentView.mas_left).with.offset(20);
            make.width.mas_equalTo((SCREEN_WIDTH-40)*three1Per);
            make.height.mas_equalTo(15);
        }];
        [_Three2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_Three.mas_bottom).with.offset(2);
            make.right.equalTo(ws.contentView.mas_right).with.offset(-20);
            make.width.mas_equalTo((SCREEN_WIDTH-40)*three2Per);
            make.height.mas_equalTo(15);
        }];
    }
    
    float for1Per = self.four1Per/100.00;
    float for2Per = 1-for1Per;
    if (for1Per>0) {
        
        [_four1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_Four.mas_bottom).with.offset(2);
            make.left.equalTo(ws.contentView.mas_left).with.offset(20);
            make.width.mas_equalTo((SCREEN_WIDTH-40)*for1Per);
            make.height.mas_equalTo(15);
        }];
        [_four2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_Four.mas_bottom).with.offset(2);
            make.right.equalTo(ws.contentView.mas_right).with.offset(-20);
            make.width.mas_equalTo((SCREEN_WIDTH-40)*for2Per);
            make.height.mas_equalTo(15);
        }];
    }

}

@end
